"use client";
import { useRouter } from "@/i18n";
import { setHtmlFontSize } from "@/utils";
import { NextUIProvider } from "@nextui-org/system";
import { ThemeProvider } from "next-themes";
import { ThemeProviderProps } from "next-themes/dist/types";
import { ReactNode, useLayoutEffect } from "react";

export interface ProvidersProps {
    children: ReactNode;
    themeProps?: Omit<ThemeProviderProps, "children">;
}

export const Providers = ({ children, themeProps }: ProvidersProps) => {
    const router = useRouter();
    useLayoutEffect(() => {
        // 调用响应式方法
        setHtmlFontSize();
    }, []);
    return (
        <div id="app" className="bg-black">
            <NextUIProvider navigate={router.push}>
                <ThemeProvider {...themeProps}>{children}</ThemeProvider>
            </NextUIProvider>
        </div>
    );
};
